﻿<Window x:Class="ConsoleWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:NicoLiveService="clr-namespace:Co9320.NicoLiveService;assembly=NicoLiveService"
    Title="Nicevote Console" Height="480" Width="450">
    <Window.Resources>
        <ObjectDataProvider x:Key="CookieSource"
                            MethodName="GetValues"
                            ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
            <x:Type TypeName="NicoLiveService:CookieSource" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
            
        <StackPanel>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBlock Text="Live ID:" Margin="3" VerticalAlignment="Center" />
                <TextBox Grid.Column="1" Margin="3" VerticalAlignment="Center"
                     Text="{Binding Path=LiveProgramIdText, UpdateSourceTrigger=PropertyChanged}" 
                     HorizontalAlignment="Stretch" 
                     Width="100" />

                <TextBlock Grid.Column="2" Text="Cookie:" Margin="3" VerticalAlignment="Center" />
                <ComboBox Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Left"
                      ItemsSource="{Binding Source={StaticResource CookieSource}}"
                      SelectedItem="{Binding CookieSource}"/>
            </Grid>
        </StackPanel>
        
        <StackPanel Grid.Column="1" VerticalAlignment="Center">
            <Button Content="接続" Command="{Binding ConnectCommand}" Margin="3" />
            <Button Content="切断" Command="{Binding DisconnectCommand}" Margin="3" />
        </StackPanel>
        
        <StackPanel Grid.Row="1">

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock Text="タイトル:" Margin="3" VerticalAlignment="Center" />
                <TextBox Grid.Column="1" Margin="3" VerticalAlignment="Center"
                         Text="{Binding Path=VoteTitle, UpdateSourceTrigger=PropertyChanged}" />
            </Grid>

            <CheckBox Margin="3" x:Name="AutoVoteItemAddingCheckBox"
                      Content="コメントから自動で項目追加" IsChecked="{Binding AutoVoteItemAdding}" />
            <Grid Margin="10 0 0 0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock Text="追加コマンド文字列:" Margin="3" VerticalAlignment="Center" />
                <TextBox Grid.Column="1" Margin="3" VerticalAlignment="Center"
                         Text="{Binding Path=AddCommandString, UpdateSourceTrigger=PropertyChanged}" />
            </Grid>

            <CheckBox Margin="3" 
                      Content="放送者コメントからのみ自動追加" IsChecked="{Binding AllowCasterCommentOnly}"
                      IsEnabled="{Binding ElementName=AutoVoteItemAddingCheckBox, Path=IsChecked}" />
            <CheckBox Margin="3" 
                      Content="複数項目への投票を許可する" IsChecked="{Binding AllowPluralVoting}" />
            <CheckBox Margin="3" 
                      Content="184(匿名)コメントからの投票のみ許可する" IsChecked="{Binding AllowVotingByAnonymityOnly}" />

        </StackPanel>

        <StackPanel Grid.Row="1" Grid.Column="1">
            <Button Content="開始" Command="{Binding StartVoteCommand}" Margin="3" />
            <Button Content="終了" Command="{Binding StopVoteCommand}" Margin="3" />
            <Button Content="表示位置..." Command="{Binding SelectDisplayAreaCommand}" Margin="3" />
            <Button Content="フォント..." Command="{Binding SelectFontCommand}" Margin="3" />

        </StackPanel>
        
        <Grid Grid.Row="2" Margin="3">
            <!--<Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>-->

            <!--<Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock Text="コメ番:" Margin="3" VerticalAlignment="Center" />  
                <TextBox Grid.Column="1" Text="{Binding ElementName=CommentsListBox, Path=SelectedItem.No, UpdateSourceTrigger=PropertyChanged}" />
            </Grid>-->

            <ListBox Margin="0 0 0 0"
                     x:Name="CommentsListBox"
                     ItemsSource="{Binding CommentsView}"
                     IsSynchronizedWithCurrentItem="True">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=No, StringFormat=0:}" Margin="0 0 3 0" />
                            <TextBlock Text="{Binding Text}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>

        <StackPanel Grid.Row="2" Grid.Column="1">
            <Button Content="項目追加" Command="{Binding AddVoteItemCommand}" Margin="3" />
            <Button Content="項目削除" Command="{Binding DeleteVoteItemCommand}" Margin="3" />
            <Button Content="全項目削除" Command="{Binding DeleteAllVoteItemsCommand}" Margin="3" />
            <Button Content="投票数リセット" Command="{Binding ResetVoteCountCommand}" Margin="3" />
            <Button Content="NGユーザー追加" Command="{Binding AddNgUserCommand}" Margin="3" />
        </StackPanel>
       
        <Expander Header="Debug" Grid.Row="3" Grid.ColumnSpan="2">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <TextBox x:Name="IdTextBox" Width="30" Margin="3" Text="id" />
                <TextBox x:Name="PremiumTextBox" Grid.Column="1" Width="30" Margin="3" Text="0" />
                <TextBox x:Name="MessageTextBox" Grid.Column="2" Margin="3" KeyDown="MessageTextBox_KeyDown" />
            </Grid>
        </Expander>
        
        <StatusBar Grid.Row="4" Grid.ColumnSpan="2">
            <StatusBarItem>
                <TextBlock Text="{Binding StatusMessage}" />
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
